<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>继承练习</title>
</head>
<body>
	<?php 

/*     
     继承允许建立一个新的派生类，从一个先前定义得类中继承数据和函数，而且可以重新定义或加进来
     新的数据和函数
     子类对父类功能得扩展
     子类可以重载父类得方法
     PHP中只能单继承
     继承中使用extends关键字
  */
class Person 
  {    protected $name;
       protected $age;
       protected $sex;

      function  __construct($name,$age,$sex){
      $this->name=$name;       
      $this->age=$age; 
      $this->sex=$sex; 
      }
  
       }
     function say(){
        echo "my name is".$this->name."my age is".$this->age."my sex is".$this->sex."<br>";
   }
      function run(){
     }	
  
  class Student extends Person{
  	var $school;
  	function study(){
      echo  $this->name."正在".$this->school."学习"."<br>";


  	}}
  	/**
  	* 
  	*/
  	class Teacher extends Student
  	{
  		 var $wage;
  		 function teach(){
echo $this->name."正在".$this->school."教学"."工资是".$this->wage."<br>";

  		 }
  	}
  
   $t1=new Teacher("zhansgan",14,"male");
   $t1->school="neusoft";
   $t1->wage=6000;
   $t1->say();
   $t1->study();
   $t1->teach();

	 ?>
</body>
</html>